package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.InsuranceBankCard;
import com.enation.app.shop.front.policyInsurance.service.InsuranceBankCardMapper;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("insuranceBankCardService")
public class InsuranceBankCardService implements InsuranceBankCardMapper {
    @Autowired
    private IDaoSupport daoSupport;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(InsuranceBankCard record) {
        this.daoSupport.insert("rbt_insurance_bankcard",record);
        return 1;
    }

    @Override
    public int insertSelective(InsuranceBankCard record) {
        return 0;
    }

    @Override
    public InsuranceBankCard selectByPrimaryKey(Long id) {
        String sql="select * from rbt_insurance_bankcard where id=?";
        return daoSupport.queryForObject(sql,InsuranceBankCard.class,id);
    }

    @Override
    public int updateByPrimaryKeySelective(InsuranceBankCard record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(InsuranceBankCard record) {
        //this.daoSupport.update("es_member", member, "member_id=" + member.getMember_id());
        this.daoSupport.update("rbt_insurance_bankcard",record,"id="+record.getId());
        return 1;
    }

    @Override
    public List<InsuranceBankCard> selectByUserId(Integer userid) {
        String sql="select * from rbt_insurance_bankcard  where user_id=? and status=1";
        return this.daoSupport.queryForList(sql,InsuranceBankCard.class,userid);
    }

    @Override
    public List<InsuranceBankCard> getAll() {
        String sql="select * from rbt_insurance_bankcard ";
        return this.daoSupport.queryForList(sql,InsuranceBankCard.class);
    }

    @Override
    public List<InsuranceBankCard> getByPage(int page, Integer limit, String seacher) {
        if (seacher==null){
            String sql="select * from  rbt_insurance_bankcard limit ?,?";
            return this.daoSupport.queryForList(sql,InsuranceBankCard.class,page,limit);
        }else {
            String sql="select * from  rbt_insurance_bankcard  where bank_user_name like '%"+seacher+"%' limit ?,?";
            return this.daoSupport.queryForList(sql,InsuranceBankCard.class,page,limit);
        }
    }

    @Override
    public List<InsuranceBankCard> getBySercher(String seacher) {
        String sql="select * from  rbt_insurance_bankcard where bank_user_name like '%"+seacher+"%'";
        return this.daoSupport.queryForList(sql,InsuranceBankCard.class);
    }
}
